<template>
  <view>
    <m-top
      :autoBack="true"
      :bgChangeByScroll="true"
      bgColor="#8C82FF"
      @getHeight="getGlHeight"
    >
      <view class="c333 font32 fw500">资讯详情</view>
    </m-top>

    <m-container :top="glTop">
      <view class="mgt32 pdv40">
        <u-swiper :list="list" height="400rpx"></u-swiper>

        <!--  -->
        <view class="mgt40">
          <panel-title>{{ detail.tmn_title }}</panel-title>
          <view class="mgt20 font28 c666">
            <u-parse :content="detail.tmn_content"></u-parse>
          </view>
        </view>
      </view>
    </m-container>
  </view>
</template>

<script>
import GlTopMixin from "@/mixins/global-top";
import PanelTitle from "@/pages/index/components/title";
import {
  getMeetingNewsDetailApi,
  getHomeNewDetailApi,
} from "@/api/modules/homepage.js";

export default {
  mixins: [GlTopMixin],
  components: { PanelTitle },
  data() {
    return {
      list: [],
      detail: {},
    };
  },

  async onLoad(options) {
    this.id = options.id;
    const from = options.from; // 来源
    uni.showLoading({
      title: "加载中",
    });
    from === "home"
      ? await this.getDetailByHome()
      : await this.getDetailDefault();
    uni.hideLoading();
  },

  methods: {
    async getDetailByHome() {
      try {
        const res = await getHomeNewDetailApi({ ti_id: this.id });
        this.detail = {
          tmn_title: res.ti_title,
          tmn_content: res.ti_content,
        };
        this.list.splice(0, 1, this.getImgUrl(res.ti_icon));
      } catch (error) {}
    },

    async getDetailDefault() {
      try {
        const res = await getMeetingNewsDetailApi({ tmn_id: this.id });
        this.detail = res;
        this.list.splice(0, 1, this.getImgUrl(res.tmn_icon));
      } catch (error) {
        debugger
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.location {
  image {
    width: 24rpx;
    height: 32rpx;
  }
}
</style>
